package exer;

/**
 * @author shkstart
 * @create 2022-08-13-16:49
 */
public class Num82 {
    public ListNode deleteDuplicates(ListNode head) {

        ListNode dummyHead = new ListNode(101);
        dummyHead.next = head;
        ListNode perv = dummyHead;
        ListNode cur = perv.next;
        while (perv.next != null) {

        ListNode next = cur.next;
            if(cur.next==null){
                return dummyHead.next;
            }

            if (cur.val == next.val) {
                while(cur.val==next.val){
                    next = next.next;
                }
                perv.next=next;
                cur = perv.next;
            }else{
                cur = cur.next;
                perv = perv.next;
            }
        }
        return dummyHead.next;
    }
}
